package jp.co.sharp.android.parents.kidsguard.common;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import jp.co.sharp.android.parents.kidsguard.R;

/**
 *　待っている Dlg
 */
public class DealWithWaitingDlg extends Dialog {

    private String mDlgMessage;
    private boolean mLoading;

    public DealWithWaitingDlg(@NonNull Context context, String pDlgMessage, boolean pLoading) {
        super(context);
        this.mDlgMessage = pDlgMessage;
        this.mLoading = pLoading;
    }

    public DealWithWaitingDlg(@NonNull Context context, int themeResId, String pDlgMessage, boolean pLoading) {
        super(context, themeResId);
        this.mDlgMessage = pDlgMessage;
        this.mLoading = pLoading;
    }

    protected DealWithWaitingDlg(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener, String pDlgMessage, boolean pLoading) {
        super(context, cancelable, cancelListener);
        this.mDlgMessage = pDlgMessage;
        this.mLoading = pLoading;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dlg_dealwith_waiting);

        TextView noLoadingDlgMsg = (TextView)findViewById(R.id.noLoadingDlgMsg);
        TextView loadingDlgMsg = (TextView)findViewById(R.id.loadingDlgMsg);
        noLoadingDlgMsg.setText(mDlgMessage);
        loadingDlgMsg.setText(mDlgMessage);

        LinearLayout noLoadingRegion = (LinearLayout)findViewById(R.id.noLoadingRegion);
        LinearLayout loadingRegion = (LinearLayout)findViewById(R.id.loadingRegion);
        if (mLoading) {
            loadingRegion.setVisibility(View.VISIBLE);
            noLoadingRegion.setVisibility(View.GONE);
        } else {
            loadingRegion.setVisibility(View.GONE);
            noLoadingRegion.setVisibility(View.VISIBLE);
        }
    }
}
